/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cooperativa.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.cooperativa.entities.Socio;

/**
 *
 * @author giovanny
 */
@Stateless
public class SocioFacade extends AbstractFacade<Socio> {
    @PersistenceContext(unitName = "CooperativaPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public SocioFacade() {
        super(Socio.class);
    }
    
    /***El siguiente metodo sirve para verificar que el socio esta registrado***/
    public Socio buscarSocioPorCodigoDao(String codigo) {
        try {

            Query q = em.createNamedQuery("Socio.findByCodigo");
            q.setParameter("codigo", codigo);

            Socio result = (Socio) q.getSingleResult();

            return result;
        } catch (Exception e) {

            return null;
        }
    }

    
}
